home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7937 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  64 lines

  1. Path: newsfeed.internetmci.com!panix!cmcl2!news!usenet
  2. From: "Edward J. Huff" <huffe@carbon.chem.nyu.edu>
  3. Newsgroups: gnu.gcc.help,comp.lang.c
  4. Subject: Is this a compiler bug?
  5. Date: Thu, 29 Feb 1996 14:30:35 -0500
  6. Organization: New York University Chemistry Dept
  7. Message-ID: <3135FEDB.65AA@carbon.chem.nyu.edu>
  8. NNTP-Posting-Host: carbon.chem.nyu.edu
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.5 sun4m)
  13.  
  14. The gcc documentation states:
  15. > If the compiler does not produce an error message for invalid 
  16. > input, that is a compiler bug. However, you should note that 
  17. > your idea of "invalid input" might be my idea of "an extension"
  18. > or "support for traditional practice".
  19.  
  20. Is this a bug?  Or is it "support for traditional practice"?
  21.  
  22. carbon% head static*.c
  23. ==> static_bug.c <==
  24. static const char foo[];
  25.  
  26. int
  27. main(int argc, const char *argv[]) {
  28.   printf("foo = '%s'\n",foo);
  29.   return 0;
  30. }
  31.  
  32. #ifdef DEFINE_IT
  33. static const char foo[] = "bar";
  34. #endif
  35.  
  36. ==> static_bug2.c <==
  37. const char foo[] = "baz";
  38. carbon% gcc static*.c
  39. carbon% a.out
  40. foo = 'baz'
  41. carbon% gcc -DDEFINE_IT static*.c
  42. carbon% a.out
  43. foo = 'bar'
  44.  
  45. The above happens on 
  46. GNU C version 2.6.3 (sparc) compiled by GNU C version 2.6.3.
  47. running on
  48. SunOS carbon 5.5 Generic sun4m sparc SUNW,SPARCstation-20
  49. and identically on
  50. GNU C version 2.7.2 [AL 1.1, MM 40] SGI running IRIX 5.x compiled by CC.
  51. running on 
  52. IRIX archimedes 5.3 11091810 IP17 mips.
  53.  
  54. The IRIX C compiler gives an error:
  55.  
  56. archimedes 23% cc static*.c
  57. static_bug.c:
  58. cfe: Error: static_bug.c, line 1: storage size for 'foo' isn't known
  59.  static const char foo[];
  60.  ------------------^
  61.  
  62. --
  63. huffe@carbon.chem.nyu.edu (Edward J. Huff) 212-998-8465
  64.